find_package(Protobuf REQUIRED)
file(GLOB_RECURSE PROTO_FILES "${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto")
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})

include_directories(
    ${Protobuf_INCLUDE_DIRS}
    ${CMAKE_CURRENT_BINARY_DIR}  # 自动生成的头文件路径
    ${CMAKE_CURRENT_SOURCE_DIR}/proto  # 原始proto文件路径
)

file(GLOB TEST_CPP_FILES ./*.cc)

foreach(TEST_FILE ${TEST_CPP_FILES})
    get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
    add_executable(${TEST_NAME}
        ${TEST_FILE}
        ${PROTO_SRCS}  # 自动生成的.pb.cc文件
        ${PROTO_HDRS}  # 自动生成的.pb.h文件
    )   
    target_link_libraries(${TEST_NAME} PRIVATE
        ${DEPEND_LIBS}
        ${Protobuf_LIBRARIES}
    )
endforeach()